/*
 * Copyright (C) 2000-2007 Wang Pengcheng <wpc0000@163.com>
 * Licensed to the Wang Pengcheng under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The LGPL licenses this file to You under the GNU Lesser General Public
 * Licence, Version 2.0  (the "License"); you may not use this file except in
 * compliance with the License.  You may obtain a copy of the License at
 *
 *     http://www.gnu.org/licenses/lgpl.txt
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
//28 Aug 2007
package cn.edu.whu.data;

/**
 * The class-field element
 * @author wpc
 *
 */
public class Data {
	//name in the class
	private String name;
	//type in the class
	private String type;
	//Getter and setter basic name
	private String methodName;
	//database-table column name
	private String databaseName;
	//unique or not in the table values.
	private boolean only;
	
	public Data(){	
	}
	
	public Data(String type,String name,boolean only){
		this.type=type;
		this.name=name;
		this.only=only;
		
		String tmp=name;
		tmp=tmp.substring(1);
		methodName= Character.toUpperCase(name.charAt(0))+tmp;
		
		tmp="";
		for(int i=0;i<name.length();i++){
			if(name.charAt(i)<='Z'){
				tmp+="_"+name.charAt(i);
			}else{
				tmp+=name.charAt(i);
			}
		}
		//TODO set the databaseName
		//databaseName=tmp.toUpperCase();
		databaseName = tmp.toLowerCase();
	}
	
	public String toString(){
		String s;
		s=type+" "+name+"\n"
			+"methodName="+methodName+"\n"
			+"databaseName="+databaseName;
		return s;
	}
	
	public static void main(String[] args){
		System.out.println(new Data("int","parentIdHelp",true));
	}

	public String getDatabaseName() {
		return databaseName;
	}

	public void setDatabaseName(String databaseName) {
		this.databaseName = databaseName;
	}

	public String getMethodName() {
		return methodName;
	}

	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isOnly() {
		return only;
	}

	public void setOnly(boolean only) {
		this.only = only;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

}
